﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using NLog.Targets;

namespace LogToDB
{
    class Util
    {
       public static void WriteLog(string message)
        {
            FileTarget target = new FileTarget();
            target.Layout = "${longdate} ${logger} ${message}";
            target.FileName = "${basedir}/logs/err.log";
            target.KeepFileOpen = false;
            target.Encoding = Encoding.UTF8;

            NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug);

            Logger logger = LogManager.GetLogger("程序错误日志");
            logger.Debug(message);
        }
    }
}
